import { Notification } from 'element-ui'

export function successMsg(msg) {
  Notification({
    title: '成功',
    message: msg,
    type: 'success'
  })
}

export function errorMsg(msg) {
  Notification({
    title: '失败',
    message: msg,
    type: 'error'
  })
}
export function formatTime(t) {
  return t.getFullYear() + '-' + (t.getMonth() + 1) + '-' + t.getDate() + ' ' + t.getHours() + ':' + t.getMinutes() + ':' + t.getSeconds()
}

export const pickerOptions = {
  shortcuts: [{
    text: '最近一周',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近一个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近三个月',
    onClick(picker) {
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      // eslint-disable-next-line no-undef
      picker.$emit('pick', [start, end])
    }
  },
  {
    text: '未来一周',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      end.setTime(start.getTime() + 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '未来一个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      end.setTime(start.getTime() + 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '未来三个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      end.setTime(start.getTime() + 3600 * 1000 * 24 * 90)
      picker.$emit('pick', [start, end])
    }

  }

  ]
}

